package com.ruoyi.wx.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.wx.mapper.VehiclesMapper;
import com.ruoyi.wx.domain.Vehicles;
import com.ruoyi.wx.service.IVehiclesService;

import javax.annotation.Resource;

/**
 * 车辆信息Service业务层处理
 *
 * @author oy
 * @date 2022-12-13
 */
@Service
public class VehiclesServiceImpl implements IVehiclesService
{
    @Resource
    private VehiclesMapper vehiclesMapper;

    /**
     * 查询车辆信息
     *
     * @param carId 车辆信息主键
     * @return 车辆信息
     */
    @Override
    public Vehicles selectVehiclesByCarId(Long carId)
    {
        return vehiclesMapper.selectVehiclesByCarId(carId);
    }

    /**
     * 查询车辆信息列表
     *
     * @param vehicles 车辆信息
     * @return 车辆信息
     */
    @Override
    public List<Vehicles> selectVehiclesList(Vehicles vehicles)
    {
        return vehiclesMapper.selectVehiclesList(vehicles);
    }

    /**
     * 新增车辆信息
     *
     * @param vehicles 车辆信息
     * @return 结果
     */
    @Override
    public int insertVehicles(Vehicles vehicles)
    {
        return vehiclesMapper.insertVehicles(vehicles);
    }

    /**
     * 修改车辆信息
     *
     * @param vehicles 车辆信息
     * @return 结果
     */
    @Override
    public int updateVehicles(Vehicles vehicles)
    {
        vehicles.setUpdateTime(DateUtils.getNowDate());
        return vehiclesMapper.updateVehicles(vehicles);
    }

    /**
     * 批量删除车辆信息
     *
     * @param carIds 需要删除的车辆信息主键
     * @return 结果
     */
    @Override
    public int deleteVehiclesByCarIds(Long[] carIds)
    {
        return vehiclesMapper.deleteVehiclesByCarIds(carIds);
    }

    /**
     * 删除车辆信息信息
     *
     * @param carId 车辆信息主键
     * @return 结果
     */
    @Override
    public int deleteVehiclesByCarId(Long carId)
    {
        return vehiclesMapper.deleteVehiclesByCarId(carId);
    }

    /**
     * 根据车牌号查询车辆id
     * @param carNo
     * @return
     */
    public Vehicles selectVehicleByCarNo(String carNo){
        return vehiclesMapper.selectVehicleByCarNo(carNo);
    }
}
